home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Utilities / Interfaces / TempRef.th < prev    next >
Encoding:
Text File  |  1996-04-22  |  1.6 KB  |  75 lines  |  [TEXT/MPS ]

  1. /*
  2. #    File:        TempRef.th
  3. #
  4. #    Contains:    Internal header for use by TempObj.h
  5. #
  6. #    Owned by:    Jens Alfke
  7. #
  8. #    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. #
  10. #    
  11. #    In Progress:
  12. #        
  13. */
  14.  
  15. // This header is a utility used by TempObj.h. Do not include it directly unless you
  16. // really know what you're doing -- see the Tech Note "Temporary Objects/References".
  17.  
  18. #ifndef SOM_ODDocument_xh
  19. #include <Document.xh>
  20. #endif
  21.  
  22. #ifndef _T_
  23. #error _T_ must be defined before including a .th file
  24. #endif
  25. #ifndef _C_
  26. #error _C_ must be defined before including a .th file
  27. #endif
  28.  
  29. //===========================================================================
  30. //    TempObj <T>
  31. //===========================================================================
  32.  
  33. #ifdef _TMPL_IMPL_
  34.  
  35.     // Implementation of the TempRef constructor:
  36.     _C_::_C_( _T_ *obj )
  37.     {
  38.         fObj = obj;
  39.     }
  40.  
  41.     _C_::~_C_( )
  42.     {
  43.         // Prevent compiler from inlining synthesized destructor
  44.         // which causes code bloat.
  45.     }
  46.  
  47. #else
  48.  
  49.     #if defined(__SC__) || defined(__MRC__)
  50.     // Some of the typecasts below offend certain compilers.
  51.     #pragma options(!warn_cast_incomplete_type)
  52.     #endif
  53.  
  54.     // Declaration of the TempRef class
  55.     class _C_ :public BaseTempRef
  56.     {
  57.         public:
  58.         _C_( _T_* );
  59.         virtual ~_C_( );
  60.         _T_* operator-> ()            {return (_T_*)fObj;}
  61.         operator _T_* ()            {return (_T_*)fObj;}
  62.         _T_* operator=( _T_ *t )    {fObj=(ODRefCntObject*)t; return t;}
  63.         
  64.         _T_* DontRelease()            {_T_* temp=(_T_*)fObj; fObj=kODNULL; return temp;}
  65.     };
  66.  
  67.     #if defined(__SC__) || defined(__MRC__)
  68.     #pragma options(warn_cast_incomplete_type)    // undo previous pragma
  69.     #endif
  70. #endif
  71.  
  72. #undef _T_
  73. #undef _C_
  74.  
  75.